package com.cp.weixin.blog.service.impl;

import com.cp.weixin.blog.dao.ContactMapper;
import com.cp.weixin.blog.repository.Contact;
import com.cp.weixin.blog.service.ContactService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;

@Service
public class ContactServiceImpl implements ContactService {

    @Autowired
    ContactMapper contactMapper;
    @Override
    public int addContact(String name, String email, String phone, String message) {
        Contact contact = new Contact();
        contact.setName(name);
        contact.setMessage(message);
        contact.setEmail(email);
        contact.setPhone(phone);
        contact.setAdd_time(new Date());
        return contactMapper.addContact(contact);
    }

    @Override
    public int addContact(Contact contact) {
        contact.setAdd_time(new Date());
        return contactMapper.addContact(contact);
    }
}
